package main

import (
	"fmt"
)


type Point struct {
	x int
	y int
}

//非指针类型的接收器
func (p Point) Add(x,y int) Point{

	p.x = x
	p.y = y
	return p
}

//指针类型的接收器，会修改接收器变量的值
func (p *Point) PointerAdd(x,y int) *Point{

	p.x = x
	p.y = y
	return p
}

func main(){
	p1 := Point{x:1,y:2}
	p2 := p1.Add(2,1)
	fmt.Println(p2)
	fmt.Println(p1)

	p3 := Point{x:6,y:8}
	p4 := p3.PointerAdd(8,6)
	fmt.Println(p3)
	fmt.Println(*p4)
	
}